import datetime

from common.db import Base

from sqlalchemy import Column, String, Integer, DateTime, SmallInteger


class User(Base):
    __tablename__ = "user"
    
    id = Column(Integer, primary_key=True, autoincrement=True)
    name = Column(String(32), nullable=False, comment="用户名")
    # 48个字符，唯一
    email = Column(String(48), unique=True, nullable=False, comment="邮箱")
    # 存放密文，默认True可以为空，False不可为空
    pwd = Column(String(128), nullable=False, comment="密码")
    create_time = Column(DateTime, default=datetime.datetime.now,
                         comment="创建时间")
    # onupdate=True自动更新时间
    update_time = Column(DateTime, default=datetime.datetime.now, onupdate=True,
                         comment="更新时间")
    # 1删，0不删除
    is_delete = Column(SmallInteger, server_default="0", comment="是否删除")
    # 是否激活， 0不激活，1激活
    is_active = Column(SmallInteger, server_default="1", comment="是否激活")
    
    

